#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QLabel>   //标签
#include <QPushButton>  //按钮
#include <QLineEdit>    //编辑框   ctrl+/注释
#include <QMessageBox>
#include <QFile>
#include <QImage>
#include <QPainter>
#include "code/playcodevideo.h"
#include "view/loginwidget.h"
#include "code/encodevideo.h"
#include "model/configuremodel.h"
#include "model/imagemodel.h"
#include "view/photowidget.h"
#include <QFileInfo>
#include <QCloseEvent>
#include "view/playbackwidget.h"
#include "view/trancewidget.h"
#include "view/logwidget.h"

class MainWidget : public QWidget
{
    Q_OBJECT
public:
    MainWidget(QWidget *parent = nullptr);
    ~MainWidget();

    void init_window();
    void init_control();
    void init_connect();
    void init_qss();


    //提供给设置界面公有的线程启动方法
    PlaycodeVideo *getPlaycode() const;

private:
    QLabel *title;
    QPushButton *takePhotoBtn, *viewPhotoBtn, *replayBtn, *viewLogBtn,
    *trancevideoBtn, *setBtn, *LoginBackBtn;

    PlaycodeVideo * playcode;
    QImage image;
    LoginWidget * loginwin;
    PhotoWidget *photowin;
    PlayBackWidget *playWidget;
    TranceWidget * trancewidget;

    LogWidget *logWidget;
    // QWidget interface
protected:
    void paintEvent(QPaintEvent *event);
public slots:
    void receiveImg(QImage img);
    //没有登录直接返回
    void showMain1();
    //登陆成功后
    void showMain2();

    void toLoginWin();
    //去照片界面
    void toPhotoWin();
    //从照片界面返回
    void showMain3();
    //void showMainWin();

    //拍照功能
    void takePhoto();

    //录像回放界面
    void toRePlayWin();
    //从录像回放界面返回
    void showMain4();

    //查看日志界面
    void toViewLogWin();

    //录像转码界面
    void toTranceWin();

    //从转码界面返回
    void showMain5();

    //从日志界面返回
    void showMain6();


signals:
    void backToSet();

    // QWidget interface
protected:
    void closeEvent(QCloseEvent *event);
};

#endif // MAINWIDGET_H
